package com.haiyi.software.app;

import java.util.HashMap;
import java.util.Map;

import com.google.gson.JsonObject;
import com.haiyi.software.app.basic.ActivityBasicReport;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class ActivityReport extends ActivityBasicReport {

	private String str_uid, str_name, str_username;

	private TextView textview_reportedUID, textview_reportedName,
			textview_reportedUsername;

	private EditText Editx_report;

	private Button btn_report;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO 自动生成的方法存根
		super.onCreate(savedInstanceState);

		setContentView(R.layout.activity_report);

		getParam();

		initCom();

		initData();
	}

	private void initData() {

		textview_reportedUID.setText(str_uid);
		textview_reportedName.setText(str_name);
		textview_reportedUsername.setText(str_username);

	}

	private void initCom() {
		// TODO 自动生成的方法存根
		textview_reportedUID = (TextView) this
				.findViewById(R.id.textview_reportedUID);
		textview_reportedName = (TextView) this
				.findViewById(R.id.textview_reportedName);
		textview_reportedUsername = (TextView) this
				.findViewById(R.id.textview_reportedUsername);

		Editx_report = (EditText) this.findViewById(R.id.Editx_report);

		btn_report = (Button) this.findViewById(R.id.btn_report);

		btn_report.setOnClickListener(btnClick);
	}

	private void getParam() {
		// TODO 自动生成的方法存根

		str_uid = this.getIntent().getStringExtra("reportedUID");
		str_name = this.getIntent().getStringExtra("reportedName");
		str_username = this.getIntent().getStringExtra("reportedUsername");
	}

	private OnClickListener btnClick = new OnClickListener() {

		@Override
		public void onClick(View v) {

			String str_report = Editx_report.getText().toString().trim();
			if (str_report.length() > 0) {
				Map<String, String> map = new HashMap<String, String>();
				map.put("reportedUid", str_uid);
				map.put("rDesc", str_report);
				requestNetworkData(map);
			}
		}
	};

	@Override
	protected void requestFinish(JsonObject jsonObjectReturn) {

		JsonObject jo = jsonObjectReturn;

		Toast.makeText(this, jo.get("desc").getAsString(), Toast.LENGTH_LONG)
				.show();
	}

	@Override
	protected void requestError() {
		// TODO 自动生成的方法存根

	}

}
